import React, { Component } from 'react'
import Seat from '../components/Seat'

export default class Film extends Component {
  constructor(props){
    super(props);
    this.state = {
        sellList:[{x:1,y:1,selled:true},{x:2,y:2,selled:true}],
    }
  }
  addSellList = (item)=>{//赋值
      this.setState({
        sellList:[...this.state.sellList,item]
      })
  }
  delSellList = (item)=>{//删除
    this.setState({
      sellList:this.state.sellList.filter(info=>info!==item)
    })

  }
  confirm = ()=>{
    // //获取第几排 第几列 卖了
    // console.log(this.state.sellList);
    if(this.state.sellList.length){
      //这里需要做什么?
      this.setState({
        sellList:this.state.sellList.map(item=>{
          item.selled=true;
          return item;
        })
      })
    }else{
      alert("请选择一个座位");
    }
  }
  render() {
    return (
      <div>
        <Seat  sellList={this.state.sellList} addSellList={this.addSellList} delSellList={this.delSellList}></Seat>
        <button onClick={this.confirm}>确定</button>
      </div>
    )
  }
}
